import trainApi from 'api/train'
const state = {
  schoolList: [],
  train_currilum_list: [], // 课程列表数据
  train_class_list: [], // 班级列表数据
  train_teacher_list: [], // 所有教练数据
  train_selectclass_list: [], // 所有课程下拉列表
  train_coach_list: [], // 教练管理列表
  train_coach_course: [], // 教练授课课程
  train_coach_info: [], // 教练信息
  country_list: [], // 国家列表
  train_student_list: [], // 学员管理列表
  train_student_detail: [], // 学员详情
  train_student_course_list: [], // 获取学员在上课程列表
  train_student_info: [], // 获取编辑的学员信息
  train_student_course_info: [], // 获取上课情况信息
  train_student_course: [], // 获取学员详情上课情况列表
  train_scholl_type_list: [], // 根据课程ID获取校区数据
  train_class_type_list: [], // 根据课程ID获取班别数据
  train_class_student: [], // 班级学员列表
  train_student_vacate: [], // 根据学员ID获取请假课时信息
  train_student_close_vacate: [], // 根据学员ID获取撤销请假课时信息
  train_course_time_count: [],
  train_course_campus_class: [], // 获取课程校区班别
  train_student_make_up: [], // 获取学员补课中的缺课信息
  train_makeup__course_info: [] // 获取学员补课课程的课时信息
}

const getters = {
  train_currilum_list: state => state.train_currilum_list,
  train_class_list: state => state.train_class_list,
  train_teacher_list: state => state.train_teacher_list,
  train_selectclass_list: state => state.train_selectclass_list,
  train_coach_list: state => state.train_coach_list,
  train_coach_course: state => state.train_coach_course,
  train_coach_info: state => state.train_coach_info,
  country_list: state => state.country_list,
  train_student_list: state => state.train_student_list,
  train_student_detail: state => state.train_student_detail,
  train_student_course_list: state => state.train_student_course_list,
  train_student_info: state => state.train_student_info,
  train_student_course_info: state => state.train_student_course_info,
  train_student_course: state => state.train_student_course,
  train_scholl_type_list: state => state.train_scholl_type_list,
  train_class_type_list: state => state.train_class_type_list,
  train_class_student: state => state.train_class_student,
  train_student_vacate: state => state.train_student_vacate,
  train_student_close_vacate: state => state.train_student_close_vacate,
  train_course_time_count: state => state.train_course_time_count,
  train_course_campus_class: state => state.train_course_campus_class,
  train_student_make_up: state => state.train_student_make_up,
  train_makeup__course_info: state => state.train_makeup__course_info
}

const actions = {
  train_currilum_list ({commit, state}, params) {
    trainApi.getListCurrculum(params).then((json) => {
      commit('TRAIN_CURRILUM_LIST', json.data)
    })
  },
  train_class_list ({commit, state}, params) {
    trainApi.listPageInfo(params).then((json) => {
      commit('TRAIN_CLASS_LIST', json.data)
    })
  },
  train_teacher_list ({commit, state}) {
    trainApi.teacherList().then((json) => {
      commit('TRAIN_TEACHER_LIST', json.data)
    })
  },
  train_selectclass_list ({commit, state}) {
    trainApi.classList().then((json) => {
      commit('TRAIN_SELECTCLASS_LIST', json.data)
    })
  },
  train_coach_list ({commit, state}, params) {
    state.train_coach_list = {}
    trainApi.coachList(params).then((json) => {
      commit('TRAIN_COACH_LIST', json.data)
    })
  },
  train_coach_course ({commit, state}, params) {
    trainApi.coachCourseDetail(params).then((json) => {
      commit('TRAIN_COACH_COURSE', json.data)
    })
  },
  train_coach_info ({commit, state}, params) {
    trainApi.coachInfo(params).then((json) => {
      commit('TRAIN_COACH_INFO', json.data)
    })
  },
  country_list ({commit, state}, params) {
    trainApi.countryList(params).then((json) => {
      commit('COUNTRY_LIST', json.data)
    })
  },
  train_student_list ({commit, state}, params) {
    state.train_student_list = {}
    trainApi.studentList(params).then((json) => {
      commit('TRAIN_STUDENT_LIST', json.data)
    })
  },
  train_student_detail ({commit, state}, params) {
    trainApi.studentDetail(params).then((json) => {
      commit('TRAIN_STUDENT_DETAIL', json.data)
    })
  },
  train_student_course_list ({commit, state}, params) {
    state.train_student_course_list = {}
    trainApi.studentCourseList(params).then((json) => {
      commit('TRAIN_STUDENT_COURSE_LIST', json.data)
    })
  },
  train_student_info ({commit, state}, params) {
    trainApi.studentInfo(params).then((json) => {
      commit('TRAIN_STUDENT_INFO', json.data)
    })
  },
  train_student_course_info ({commit, state}, params) {
    trainApi.studentCourseInfo(params).then((json) => {
      commit('TRAIN_STUDENT_COURSE_INFO', json.data)
    })
  },
  train_student_course ({commit, state}, params) {
    trainApi.studentCourse(params).then((json) => {
      commit('TRAIN_STUDENT_COURSE', json.data)
    })
  },
  train_scholl_type_list ({commit, state}, params) {
    state.train_scholl_type_list = []
    trainApi.getSchoolList(params).then((json) => {
      commit('TRAIN_SCHOLL_TYPE_LIST', json.data)
    })
  },
  train_class_type_list ({commit, state}, params) {
    state.train_class_type_list = []
    trainApi.getClasstypeList(params).then((json) => {
      commit('TRAIN_CLASS_TYPE_LIST', json.data)
    })
  },
  train_class_student ({commit, state}, params) {
    trainApi.classStudentInfo(params).then((json) => {
      commit('TRAIN_CLASS_STUDENT', json.data)
    })
  },
  train_student_vacate ({commit, state}, params) {
    trainApi.studentVacate(params).then((json) => {
      commit('TRAIN_STUDENT_VACATE', json.data)
    })
  },
  train_student_close_vacate ({commit, state}, params) {
    trainApi.studentCloseVacate(params).then((json) => {
      commit('TRAIN_STUDENT_CLOSE_VACATE', json.data)
    })
  },
  train_course_time_count ({commit, state}, params) {
    trainApi.courseTimeCount(params).then((json) => {
      commit('TRAIN_COURSE_TIME_COUNT', json.data)
    })
  },
  train_course_campus_class ({commit, state}, params) {
    trainApi.courseCampusClass(params).then((json) => {
      commit('TRAIN_COURSE_CAMPUS_CLASS', json.data)
    })
  },
  train_student_make_up ({commit, state}, params) {
    trainApi.studentMakeUp(params).then((json) => {
      commit('TRAIN_STUDENT_MAKE_UP', json.data)
    })
  },
  train_makeup__course_info ({commit, state}, params) {
    trainApi.courseInfo(params).then((json) => {
      commit('TRAIN_STUDENT_MAKEUP_COURSE_INFO', json.data)
    })
  }
}

const mutations = {
  TRAIN_CURRILUM_LIST (state, data) {
    state.train_currilum_list = data
  },
  TRAIN_CLASS_LIST (state, data) {
    state.train_class_list = data
  },
  TRAIN_TEACHER_LIST (state, data) {
    state.train_teacher_list = data
  },
  TRAIN_SELECTCLASS_LIST (state, data) {
    state.train_selectclass_list = data
  },
  TRAIN_COACH_LIST (state, data) {
    state.train_coach_list = data
  },
  TRAIN_COACH_COURSE (state, data) {
    state.train_coach_course = data
  },
  TRAIN_COACH_INFO (state, data) {
    state.train_coach_info = data
  },
  COUNTRY_LIST (state, data) {
    state.country_list = data
  },
  TRAIN_STUDENT_LIST (state, data) {
    state.train_student_list = data
  },
  TRAIN_STUDENT_DETAIL (state, data) {
    state.train_student_detail = data
  },
  TRAIN_STUDENT_COURSE_LIST (state, data) {
    state.train_student_course_list = data
  },
  TRAIN_STUDENT_INFO (state, data) {
    state.train_student_info = data
  },
  TRAIN_STUDENT_COURSE_INFO (state, data) {
    state.train_student_course_info = data
  },
  TRAIN_STUDENT_COURSE (state, data) {
    state.train_student_course = data
  },
  TRAIN_SCHOLL_TYPE_LIST (state, data) {
    state.train_scholl_type_list = data
  },
  TRAIN_CLASS_TYPE_LIST (state, data) {
    state.train_class_type_list = data
  },
  TRAIN_CLASS_STUDENT (state, data) {
    state.train_class_student = data
  },
  TRAIN_STUDENT_VACATE (state, data) {
    state.train_student_vacate = data
  },
  TRAIN_STUDENT_CLOSE_VACATE (state, data) {
    state.train_student_close_vacate = data
  },
  TRAIN_COURSE_TIME_COUNT (state, data) {
    state.train_course_time_count = data
  },
  TRAIN_COURSE_CAMPUS_CLASS (state, data) {
    state.train_course_campus_class = data
  },
  TRAIN_STUDENT_MAKE_UP (state, data) {
    state.train_student_make_up = data
  },
  TRAIN_STUDENT_MAKEUP_COURSE_INFO (state, data) {
    state.train_makeup__course_info = data
  }
}

export default {
  state,
  getters,
  actions,
  mutations
}
